package bite20220325;

class Student{
    public String name;
    public int age;
    public int length;
    public double salary;//成员变量

    public Student(){
        this("lala",12);//必须放第一行,不能形成环
        System.out.println("这是不带参数的构造方法");
    }
    public Student(String name,int age){
        this.age = age;
        this.name = name;
        System.out.println("这是带有两个参数的构造方法");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", length=" + length +
                ", salary=" + salary +
                '}';
    }
}

public class Test {
    public static void main(String[] args) {
        Student student1 = new Student();
        Student student2 = new Student();//实例化，成员变量存在堆中
                //局部变量、栈区
        System.out.println(student1);
    }
}
